﻿<cfsilent>
	<cfscript>
		
		event.setArg("pageTitle", "网上成绩录入 - 成绩录入情况");
		
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		propAdvice = getProperty("serviceFactory").getBean("termPropertyAdvice");
		
		termId = event.getArg("TID", event.getArg("TermID"));
		depId = event.getArg("DepID","101");
		
		academicYear = event.getArg("AcademicYear");
		academicTerm = event.getArg("AcademicTerm");
		
		currentTab = event.getArg("TabID", "labGenerator");
		
		rs_ins = queryNew("institute_id");
		rs_departmentEntity = queryNew("institute_id");
		rs_task = queryNew("task_id");
		
		targetArgs = structNew();
		structInsert(targetArgs, "TID", termId, true);
		
		sql = "SELECT 
					a.term_id, a.academic_year, 
					a.academic_term, a.term_prop 
				FROM t_term a  
				WHERE 
					SUBSTR(a.term_prop, 1, 1) = '1' 
					OR 
					SUBSTR(a.term_prop, 6, 1) = '1'
				ORDER BY a.term_id";
				
		queryObj = new Query(datasource = application.dnsSlave);
		rs_term = queryObj.execute(sql = sql).getResult();
		
		/* 读取课程的开课学院 */
		
		sql = "	SELECT
					i.institute_id,
					i.institute_name,
					COUNT(DISTINCT c.cid) c_count,
					COUNT(*) r_count
				FROM
					t_resitplan r INNER JOIN t_course c ON c.cid = r.cid INNER JOIN t_institute i ON i.institute_id = c.institute_id
				WHERE
					r.term_id = :termId 
				GROUP BY
					i.institute_id,i.institute_name
				ORDER BY
					i.institute_name";
		
		queryObj = new Query(datasource = application.dnsSlave);
		queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
		rs_ins = queryObj.execute(sql = sql).getResult();
		
		/*if( rs_ins.recordCount){
			currentTab = event.getArg("TabID", "labDepartment");
		}*/
		
		if ( depId neq "") {
			
			structInsert(targetArgs, "DepID", depId, true);
			
			/* 任课单位信息 */
			sql = "	SELECT
						i.institute_id,i.institute_name
					FROM
						t_institute i
					WHERE
						i.institute_id = :depId ";
			
			queryObj = new Query(datasource = application.dnsSlave);
			queryObj.addParam(name = "depId", value = depId, cfsqltype = "cf_sql_varchar");
			rs_departmentEntity = queryObj.execute(sql = sql).getResult();
				
			/* 读取已激活成绩任务提交状况 */
			sql = "	SELECT
						r.task_id,r.task_type,r.task_prog,r.mark_done,r.mark_need,
						c.course_name,c.course_credit,
						c.course_code,
						r.cidx,
						i.institute_short,
						c.mark_mode
					FROM
						t_resitplan r INNER JOIN t_course c ON c.cid = r.cid INNER JOIN t_institute i ON i.institute_id = c.institute_id
					WHERE
						i.institute_id = :depId 
						AND
						r.term_id = :termId 
					ORDER BY
						r.task_prog DESC,c.course_name,r.cidx";
			
			queryObj = new Query(datasource = application.dnsSlave);
			queryObj.addParam(name = "depId", value = depId, cfsqltype = "cf_sql_varchar");
			queryObj.addParam(name = "termId", value = termId, cfsqltype = "cf_sql_char");
			rs_task = queryObj.execute(sql = sql).getResult();
			
			if( rs_task.recordCount ){
				currentTab = "labTask";	
			}
			
		}
		
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('DEFAULT_EVENT')#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">网上成绩录入</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput>学期补考成绩提交情况
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
			
				<div class="UItab">
					<div class="tabLables">
                         	<span <cfif currentTab eq "labGenerator">class="active"</cfif> id="labGenerator" tabTarget="Generator">生成补考名单</span>
                              <span <cfif currentTab eq "labClear">class="active"</cfif> id="labClear" tabTarget="Clear">清除补考数据</span>
						<!---<span <cfif currentTab eq "labDepartment">class="active"</cfif> id="labDepartment" tabTarget="Department">开课部门</span>--->
						<cfif rs_task.recordCount>
							<span <cfif currentTab eq "labTask">class="active"</cfif> id="labTask" tabTarget="Task">成绩提交状态</span>
						</cfif>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
				
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
				
					});
					// -->
					//]]>
				</script>
                    
                    <div id="Generator" class="tabContent">
					
					<div class="systemNotice">
						<h3><span class="img icon16x16 info"></span>请仔细核对</h3>
						<p>系统将根据不及格、缺考和补缓考的学生, 自动生成补考学生名单（用于提交补考成绩）.</p>
					</div>
					
					<form id="formRequired" onSubmit="javascript:return processVerfiyForm('formRequired');" class="formWrapper" method="post" action="<cfoutput>#buildURL('examResitCourseDo')#</cfoutput>">
						
						<div class="label">
							<b>课程授课学期</b>
                            <cfloop query="rs_term" >
								<cfset propAdvice.parseProperty(rs_term.term_prop) />
								<cfif propAdvice.getRunning()>
									<cfoutput>#rs_term.academic_year#</cfoutput> 学年 - <cfoutput>#dictAdvice.getTerm(rs_term.academic_term)#</cfoutput>
									<input name="markTerm" id="markTerm" type="hidden" value="<cfoutput>#rs_term.term_id#</cfoutput>" />
								</cfif>
							</cfloop>
						</div>
						
						<div class="label">
							<b>补考执行时间</b>
                            <cfloop query="rs_term" >
								<cfset propAdvice.parseProperty(rs_term.term_prop) />
								<cfif propAdvice.getForResitExam()>
									<cfoutput>#rs_term.academic_year#</cfoutput> 学年 - <cfoutput>#dictAdvice.getTerm(rs_term.academic_term)#</cfoutput>
									<input name="resitTerm" id="resitTerm" type="hidden" value="<cfoutput>#rs_term.term_id#</cfoutput>" />
								</cfif>
							</cfloop>
							
						</div>
						
						<hr/>
						
						<div class="lable">
							<input class="button1" type="submit" value="生成补考学生名单" />
						</div>
						
					</form>
					
				</div>
                    
                    <div id="Clear" class="tabContent">
					
					<div class="systemNotice">
						<h3><span class="img icon16x16 info"></span>删除课程信息</h3>
						<p>注意: 您即将进行补考安排数据清除操作. 该操作会删除指定学期的补考成绩提交名单和补考分组安排. 执行该项操作后您需要重新生成补考名单.</p>
					
						<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('examResitClearDo')#</cfoutput>">
							<input type="hidden" name="resitTerm" value="<cfoutput>#termId#</cfoutput>" />
							<div id="FirstDelete" class="lable"><input class="button2" type="button" value="清除补考安排" /></div>
							<div id="SecondDelete" class="lable hidden_elem"><input class="button2" type="submit" value="确认删除？"></div>
							
							<script type="text/javascript">
								//<![CDATA[
								<!--
								$(document).ready(function(e) {
									
									$("#FirstDelete").click(function(){
										$("#FirstDelete").addClass("hidden_elem");
										$("#SecondDelete").removeClass("hidden_elem");
									});
									
								});
								// -->
								//]]>
							</script>
						</form>
					</div>
					
				</div>

				<div id="Department" class="tabContent">
					
					<div class="noticeBlock">

						<h3>开课部门概况</h3>
						<p><span class="img icon16x16 message"></span><em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期补考共计 <em><cfoutput>#rs_ins.recordCount#</cfoutput></em> 个任课单位共同完成.</p>
						<hr/>
						
					</div>
					
					<div class="clearfix">
						<div class="UICardTable">
                            <cfloop query="rs_ins">
								<cfset structInsert(targetArgs, "DepID", rs_ins.institute_id, true) />
								<dl>
									<dt>
										<a href="<cfoutput>#buildURL('taskClassResit', targetArgs)#</cfoutput>">
										<em class="collection"><!--imgholder--></em>
										<dd>
											<h3><cfoutput>#rs_ins.institute_name#</cfoutput></h3>
											<div>课程:<cfoutput>#rs_ins.c_count#</cfoutput> 教学班:<cfoutput>#rs_ins.r_count#</cfoutput></div>
										</dd>
										</a>
									</dt>
								</dl>
							</cfloop>
						</div>
					</div>
					
				</div>

				<div id="Task" class="tabContent">
					
					<cfif rs_departmentEntity.recordCount>
						<cfset structInsert(targetArgs, "DepID", rs_departmentEntity.institute_id, true) />
						<div class="noticeBlock">
							<!---<div class="operation">
								<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('depTaskDownloadExcel', targetArgs)#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载学院教学任务</span></a>
							</div>--->
							<h3><cfoutput>#rs_departmentEntity.institute_name#</cfoutput></h3>
							<p>
								<span class="img icon16x16 message"></span>
								<em><cfoutput>#academicYear#</cfoutput>-<cfoutput>#academicTerm#</cfoutput></em>学期, 
								已网上成绩录入课程教学任务 <em><cfoutput>#rs_task.recordCount#</cfoutput></em> 个
								.
							</p>
							<hr/>
						</div>
					</cfif>
					
					<cfif rs_task.recordCount>

						<table class="UIEditable">
							<thead>
								<tr>
									<td width="30"></td>
									<td>课程</td>
									<td width="90">主讲教师</td>
									<td width="40">学分</td>
									<td width="50">部门</td>
									<td width="60">提交进度</td>
									<td width="60">计分模式</td>
									<td width="60">状态</td>
									<td width="18"></td>
								</tr>
							</thead>
							<tbody>
								<cfset row = 0 />
                                <cfloop query="rs_task">
									<cfset row++ />
									<cfset structInsert(targetArgs, "TSK", rs_task.task_id, true) />
									<cfset structInsert(targetArgs, "TT", rs_task.task_type, true) />
									<!--- 反向读取任务的主讲教师 --->
                                    <cfswitch expression="#rs_task.task_type#">
                                        <cfcase value="P">
                                        	<cfset sql = "SELECT
																t.tch_name
															FROM
																t_task tsk INNER JOIN t_teacher t ON t.tch_id = tsk.tch_id
															WHERE
																tsk.tsk_id = :taskId " />
											<cfset queryObj = new Query(datasource = application.dnsSlave) />
                                            <cfset queryObj.addParam(name = "taskId", value = rs_task.task_id, cfsqltype = "cf_sql_varchar") />
                                            <cfset rs_targetTaskEntity = queryObj.execute(sql = sql).getResult() />
                                        </cfcase>
                                        <cfcase value="C">
                                        	<cfset sql = "SELECT
																t.tch_name
															FROM
																t_common_task tsk INNER JOIN t_teacher t ON t.tch_id = tsk.tch_id
															WHERE
																tsk.tsk_id = :taskId " />
											<cfset queryObj = new Query(datasource = application.dnsSlave) />
                                            <cfset queryObj.addParam(name = "taskId", value = rs_task.task_id, cfsqltype = "cf_sql_varchar") />
                                            <cfset rs_targetTaskEntity = queryObj.execute(sql = sql).getResult() />
                                        </cfcase>
                                        <cfcase value="R">
                                        	<cfset sql = "SELECT
																t.tch_name
															FROM
																t_reopen_task tsk INNER JOIN t_teacher t ON t.tch_id = tsk.tch_id
															WHERE
																tsk.tsk_id = :taskId " />
											<cfset queryObj = new Query(datasource = application.dnsSlave) />
                                            <cfset queryObj.addParam(name = "taskId", value = rs_task.task_id, cfsqltype = "cf_sql_varchar") />
                                            <cfset rs_targetTaskEntity = queryObj.execute(sql = sql).getResult() />
                                        </cfcase>
                                        <cfcase value="T">
                                        	<cfset sql = "SELECT
																t.tch_name
															FROM
																t_sport_task tsk INNER JOIN t_teacher t ON t.tch_id = tsk.tch_id
															WHERE
																tsk.tsk_id = :taskId " />
											<cfset queryObj = new Query(datasource = application.dnsSlave) />
                                            <cfset queryObj.addParam(name = "taskId", value = rs_task.task_id, cfsqltype = "cf_sql_varchar") />
                                            <cfset rs_targetTaskEntity = queryObj.execute(sql = sql).getResult() />
                                        </cfcase>
                                    </cfswitch>
									<tr class="editRows" rowid="<cfoutput>#rs_task.task_id#</cfoutput>">
										<td class="index"><cfoutput>#row#</cfoutput></td>
										<td><cfoutput>#rs_task.course_name#</cfoutput><span class="numeric">-<cfoutput>#rs_task.cidx#</cfoutput></span></td>
										<td><cfoutput>#rs_targetTaskEntity.tch_name#</cfoutput></td>
										<td><span class="numeric"><cfoutput>#numberFormat(rs_task.course_credit, '_.__')#</cfoutput></span></td>
										<td><cfoutput>#rs_task.institute_short#</cfoutput></td>
										<td align="center"><span class="numeric"><cfoutput>#rs_task.mark_done#</cfoutput> / <cfoutput>#rs_task.mark_need#</cfoutput></span></td>
										<td align="center"><cfoutput>#dictAdvice.getMarkModeName( rs_task.mark_mode )#</cfoutput></td>
										<td class="TaskProgress<cfoutput>#rs_task.task_prog#</cfoutput>"><cfoutput>#dictAdvice.getTaskMarkStat( rs_task.task_prog )#</cfoutput></td>
										<td>
											<cfif rs_task.task_prog eq "3">
												<a title="解锁成绩" href="<cfoutput>#buildURL('taskMarkResitUnlockDo', targetArgs)#</cfoutput>" class="stat locked"></a>
											</cfif>
										</td>
									</tr>
								</cfloop>
							</tbody>
						</table>
					
					</cfif>
					
				</div>

			</div>
		</li>
	</ul>
</div>
